<template>
	<view>
		<HeaderBar title="我的推广" :opacity="opacity" color="#fff" />
		<view class="bg"></view>
		<u-gap :height="34"></u-gap>
		<view class="content">
			<view class="content-title">推广记录</view>
			<view class="content-subTitle">查看我推广的用户</view>
		</view>
		<view class="list">
			<view class="list-table">
				<view class="list-table-item">用户</view>
				<view class="list-table-item">时间</view>
			</view>
			<view class="list-title">
				<image src="/static/icn-箭头-下.png" mode=""></image>
				今日
			</view>
			<view class="list-item" v-for="it in today" :key="it.id">
				<image :src="it.avatar" mode="" class="list-item-avatar"></image>
				<view class="list-item-name">{{it.nickname || ''}}</view>
				<view class="list-item-time">{{it.updated_at || ''}}</view>
			</view>
			<view class="noData" style="padding-bottom:120rpx;" v-if="today.length === 0">
				<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
			</view>
			<view class="list-title">
				<image src="/static/icn-箭头-下.png" mode=""></image>
				今日
			</view>
			<view class="list-item" v-for="it in list" :key="it.id">
				<image :src="it.avatar" mode="" class="list-item-avatar"></image>
				<view class="list-item-name">{{it.nickname || ''}}</view>
				<view class="list-item-time">{{it.updated_at || ''}}</view>
			</view>
			<view class="noData" style="padding-bottom:120rpx;" v-if="list.length === 0">
				<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
			</view>
		</view>
	</view>
</template>

<script>
	import HeaderBar from "@/components/header/header.vue"
	import {
		userChild
	} from '@/common/http/api.js'
	export default {
		components: {
			HeaderBar
		},
		data() {
			return {
				opacity: 0,
				params: {
					page: 1 
				},
				list: [],
				isList: true,
				today: []
			};
		},
		onLoad() {
			
			this.reload()
		},
		onPullDownRefresh: function() {
			console.log('我被下拉了');
			this.list = []
			this.today = []
			this.reload(1)
		},
		methods:{
			reload(type) {
				this.params.page = 1
				this.list = []
				this.init(type)
			},
			//0 默认 1上拉
			init(type = 0) {
				uni.showLoading()
				userChild(this.params).then(res => {
					this.today = res.data.today
					this.list = res.data.list
					
				}).finally(() => {
					uni.hideLoading()
					if (type === 1) {
						uni.stopPullDownRefresh();
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.bg {
		width: 100%;
		height: 300rpx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: -1;
		background: #0065FF;

	}
	.qrCode {
		width: 100vw;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		padding: 100rpx 0;
		.qrCode-img {
			width: 400rpx;
			height: 400rpx;
			margin-bottom: 90rpx;
		}
		.qrCode-title {
			 color: #000000;
			 text-align: center;
			 font-family: "PingFang SC";
			 font-size: 28rpx;
			 font-style: normal;
			 font-weight: 500;
			 margin-bottom: 116rpx;
		}
		.qrCode-btn {
			width: 364rpx;
			height: 90rpx;
			flex-shrink: 0;
			fill: #0065FF;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #0065FF;
			 font-family: "PingFang SC";
			 font-size: 36rpx;
			 font-style: normal;
			 font-weight: 500;
			 background: #E6F0FF;
			 border-radius: 46rpx;
		}
	}
	.content {
		width: 100%;
		position: relative;
		background: white;
		box-sizing: border-box;
		padding: 0 40rpx;
		margin-bottom: 58rpx;

		.content-title {
			color: #112950;
			font-family: "PingFang SC";
			font-size: 48rpx;
			font-style: normal;
			font-weight: 400;
			margin-bottom: 4rpx;
		}

		.content-subTitle {
			color: #b2bac6;
			font-family: "PingFang SC";
			font-size: 30rpx;
			font-style: normal;
			font-weight: 400;
		}
	}

	.content::before {
		content: "";
		width: 100%;
		height: 45rpx;
		background: white;
		border-top-right-radius: 50rpx;
		position: absolute;
		top: -42rpx;
		left: 0;
	}
	.list {
		width: 100%;
		box-sizing: border-box;
		padding: 0 40rpx;
		.list-table {
			height: 64rpx;
			flex-shrink: 0;
			border-radius: 16rpx;
			background: #F4F9FD;
			display: flex;
			margin-bottom: 18rpx;
			.list-table-item {
				flex: 1;
				min-width: 0;
				display: flex;
				align-items: center;
				justify-content: center;
				 color: #3f3f44;
				 font-family: "PingFang SC";
				 font-size: 24rpx;
				 font-style: normal;
				 font-weight: 400;
			}
		}
		.list-title {
			width: 100%;
			display: flex;
			align-items: center;
			margin-bottom: 24rpx;
			image {
				width: 48rpx;
				height: 48rpx;
				margin-right: 4rpx;
			}
			 color: #3f8cff;
			 font-family: "PingFang SC";
			 font-size: 30rpx;
			 font-style: normal;
			 font-weight: 400;
		}
		.list-item {
			width: 100%;
			display: flex;
			align-items: center;
			margin-bottom: 40rpx;
			box-sizing: border-box;
			padding:0 38rpx;
			.list-item-avatar {
				width: 80rpx;
				height: 80rpx;
				flex-shrink: 0;
				border-radius: 80rpx;
				margin-right: 24rpx;
			}
			.list-item-name {
				color: #3f3f44;
				 font-family: "PingFang SC";
				 font-size: 24rpx;
				 font-style: normal;
				 font-weight: 500;
			}
			.list-item-time {
				 color: #3f3f44;
				 text-align: right;
				 font-family: "PingFang SC";
				 font-size: 24rpx;
				 font-style: normal;
				 font-weight: 500;
				 margin-left: auto;
			}
		}
	}
	
</style>